package ex.datastream.windows.keyedVsNonKeyedWindows;

import ex.datastream.ApiFrame;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.*;
import org.apache.flink.streaming.api.windowing.assigners.ProcessingTimeSessionWindows;
import org.apache.flink.streaming.api.windowing.time.Time;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;

/**
 * Non-Keyed Windows
 */
public class GlobalWindow extends ApiFrame {
    public static void main(String[] args) throws Exception {
        GlobalWindow windows = new GlobalWindow();
        windows.getEnv();

        SingleOutputStreamOperator<Tuple2<String, Long>> outputStreamOperator = windows.getSingleOutputStreamOperator();
        //无keyBy
        AllWindowedStream<Tuple2<String, Long>,TimeWindow> allWindowedStream1=outputStreamOperator.windowAll(ProcessingTimeSessionWindows.withGap(Time.seconds(5)));

        allWindowedStream1.sum(1).print();
        windows.env.execute();
    }

}
